<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>

		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			select {
				outline: none;
			}
			
			select.ly_select {
				width: 2rem;
			}
			
			#city_4 div {
				margin-right: 0.2rem;
			}
			
			select.padding-tb {
				margin-right: 0;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body class="ly-bgcolor">
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">卖家意向申请</p>
				</div>
				<div id="content" style="padding-bottom: 1.319444rem; font-size: 14px;">
					<div class="ly-form">
						<div class="ly-form-item" style="padding: 0rem 0.33rem;">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*真实姓名：</label>
								<div class="col-xs-8">
									<input class="form-control ly-input" id="name" placeholder="请输入姓名" value="" />
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*联系电话：</label>
								<div class="col-xs-8"><input id="phone" class="form-control ly-input" placeholder="请输入手机号" /></div>
							</div>
						</div>
						<!--<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*邮箱：</label>
								<div class="col-xs-8"><input id="mail" class="form-control ly-input" placeholder="请输入邮箱地址" /></div>
							</div>
						</div>-->
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*卖家地址：</label>
								<div class="col-xs-8">
									<div class="row" id="city_4">
										<div class="col-xs-3 padding-tb">
											<select id="sheng" class="ly_select prov ">
											</select>
										</div>
										<div class="col-xs-3 padding-tb">
											<select id="shi" class="ly_select city">

											</select>
										</div>
										<div class="col-xs-3 padding-tb">
											<select id="qu" class="ly_select dist">
											</select>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="ly-form-item">
							<div class="row ly-item-content">
								<label class="control-label col-xs-4 ly-form-label" style="text-align: right;">*具体地址：</label>
								<div class="col-xs-8"><input id="add" class="form-control ly-input" placeholder="请输入具体地址" /></div>
							</div>
						</div>
						<a id="submit" style="display: block;color: #fff;padding: 0.25rem;" class="ly-borderp">提交</a>
					</div>
				</div>
			</div>
		</div>

	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="jquery.cityselect.js"></script>
	<script type="text/javascript">
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					var check = false;
					for(var i = 0; i < data.roleList.length; i++) {
						var role = data.roleList[i].id;
						var deadline = new Date(data.roleList[i].deadline);
						if(role == "f1" && deadline >= new Date()) {
							check = true;
						}
						if(role == "f2" && deadline >= new Date()) {
							check = true;
						}
					}
					if(!check) {
						window.location.href = "person_MakerApplyVip.html";
					}
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}
		$(function() {
			$("#city_4").citySelect({
				prov: "--选择--",
				city: "--选择--",
				dist: "--选择--",
				nodata: "none"
			});
			var bol1 = true;
			var bol2 = true;
			$("#sheng").change(function() {
				bol1 = false;
			})
			$("#shi").change(function() {
				bol1 = false;
			})
			$("#submit").click(function() {
				console.log(bol1);
				if(bol1 || $("#name").val() == '' || $("#phone").val() == '' || $("#add").val() == '') {
					return alert("请将信息填写完整");
				}
				var pattern1 = /^1\d{10}$/; //手机号
				var pattern2 = /^\w+[@]\w+[.][\w.]+$/; //邮箱

				if(!pattern1.test($("#phone").val())) {
					return alert("请输入正确的手机号码");
				}
				/*	if(!pattern2.test($("#mail").val())) {
						return alert("请输入正确的邮箱地址");
					}*/
				$.ajax({
					type: "get",
					url: 'http://47.104.13.109/member-service/member/mine/member?token=' + $.cookie('tokenRh'),
					async: true,
					success: function(res) {
						var id = res.id;
						console.log(id)
						$.ajax({
							type: "post",
							url: "http://47.104.13.109/intention-service/tfIntentionSeller",
							async: true,
							data: {
								name: $("#name").val(),
								phone: $("#phone").val(),
								mail: "-",
								sheng: $("#sheng").val(),
								shi: $("#shi").val(),
								qu: $("#qu").val(),
								add: $("#add").val(),
								memberId: id
							},
							success: function(data) {
								console.log(data);
								alert("提交成功");
								history.go(-1);
							}
						});
					},
					error: function(res) {
						console.log(res)
					}
				})

			})

		});
	</script>

</html>